﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class control_common_TopSearchTour : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadComboKh();
            LoadComboDd();
        }
    }
    protected void LoadComboKh()
    {
        string linkweb = "?menu=175&parent=173";
        DataTable dt = DataAccess.ExeSQLToDataTable("select * from DiaDanh where CheckTour='" + linkweb + "'");
        if (dt.Rows.Count > 0)
        {
            selectKh.DataSource = dt;
            selectKh.DataTextField = "Name";
            selectKh.DataValueField = "IdYahoo";
            selectKh.DataBind();
        }
    }
    protected void CheckTour(object sender, EventArgs e)
    {
        string linkweb = "";
        linkweb = "?menu=175&parent=173";
        DataTable dt = DataAccess.ExeSQLToDataTable("select * from DiaDanh where CheckTour='" + linkweb + "'");
        if (dt.Rows.Count > 0)
        {
            selectDd.DataSource = dt;
            selectDd.DataTextField = "Name";
            selectDd.DataValueField = "IdYahoo";
            selectDd.DataBind();
        }
    }
    protected void LoadComboDd()
    {
        string linkweb = "";
        linkweb = "?menu=175&parent=173";
        DataTable dt = DataAccess.ExeSQLToDataTable("select * from DiaDanh where CheckTour='" + linkweb + "'");
        if (dt.Rows.Count > 0)
        {
            selectDd.DataSource = dt;
            selectDd.DataTextField = "Name";
            selectDd.DataValueField = "IdYahoo";
            selectDd.DataBind();
        }
    }
    protected void TimKiemClick(object sender, EventArgs e)
    {
        long idkhoihanh = Convert.ToInt64(selectKh.SelectedValue);
        long iddiemden = Convert.ToInt64(selectDd.SelectedValue);
        Response.Redirect("timkiemtourdulich.aspx?idkhoihanh=" + idkhoihanh + "&iddiemden=" + iddiemden);
    }
    protected void ChangeOpt(object sender, EventArgs e)
    {
        if (rbSearch.SelectedValue == "2")
        {
            string linkweb = "";
            linkweb = "?menu=174&parent=173";
            DataTable dt = DataAccess.ExeSQLToDataTable("select * from DiaDanh where CheckTour='" + linkweb + "'");
            if (dt.Rows.Count > 0)
            {
                selectDd.DataSource = dt;
                selectDd.DataTextField = "Name";
                selectDd.DataValueField = "IdYahoo";
                selectDd.DataBind();
            }
        }
        if (rbSearch.SelectedValue == "1")
        {
            string linkweb = "";
            linkweb = "?menu=175&parent=173";
            DataTable dt = DataAccess.ExeSQLToDataTable("select * from DiaDanh where CheckTour='" + linkweb + "'");
            if (dt.Rows.Count > 0)
            {
                selectDd.DataSource = dt;
                selectDd.DataTextField = "Name";
                selectDd.DataValueField = "IdYahoo";
                selectDd.DataBind();
            }
        }
    }
}